package com.ccb.cloud.rca.appservice.util;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.util.Collection;
import java.util.Map;

/**
 * @author wang
 * @Description
 * @create 2021-09-13 15:00
 */
public class StrUtils {
    public static boolean isNotBlank(Object o) {
        return !isBlank(o);
    }

    public static boolean isBlank(Object o) {
        if (o == null) {
            return true;
        } else if (o instanceof String) {
            return StringUtils.isBlank((String)o);
        } else if (o instanceof Collection) {
            return CollectionUtils.isEmpty((Collection)o);
        } else if (o.getClass().isArray()) {
            return ArrayUtils.isEmpty((Object[])((Object[])o));
        } else if (o instanceof Map) {
            return mapIsEmpty((Map)o);
        } else {
            return o == null;
        }
    }
    public static boolean mapIsEmpty(Map map) {
        return map == null || map.size() == 0;
    }
}
